package com.kclm.ssm.service.impl;

import com.kclm.ssm.mapper.StudentMapper;
import com.kclm.ssm.pojo.Student;
import com.kclm.ssm.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author : lvhx
 * @Date: 2025/11/11 14:26
 * @Description:
 */
@Service
public class StudentServiceImpl  implements StudentService {
    @Autowired
    private StudentMapper studentMapper;

//    public StudentServiceImpl(StudentMapper studentMapper) {
//        this.studentMapper = studentMapper;
//    }

    @Override
    public List<Student> findAll() {
        List<Student> students = studentMapper.selectAll();
        return students;
    }

    @Override
    public Student findById(Integer id) {
        Student student = studentMapper.selectById(id);
        return student;
    }

    @Override
    public boolean save(Student student) {
        int result  = studentMapper.insert(student);
        return result>0;
    }

    @Override
    public boolean modify(Student student) {
        int result = studentMapper.update(student);
        return result>0;
    }

    @Override
    public boolean delete(Integer id) {
        int result  = studentMapper.delete(id);
        return result>0;
    }

}
